<%@ page import="org.apache.ibatis.session.SqlSession" %>
<%@ page import="myschool.dao.GradeDao" %>
<%@ page import="myschool.util.MybatisUtil" %>
<%@ page import="myschool.entity.Grade" %>
<%@ page import="java.util.List" %>
<%@ page import="myschool.util.StrUtil" %>
<%@ page import="myschool.biz.StudentService" %>
<%@ page import="myschool.entity.Student" %><%--
  Created by IntelliJ IDEA.
  User: oldliu
  Date: 2023-04-10
  Time: 8:33
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>修改学生信息</title>
    <script src="js/jquery-3.6.3.min.js"></script>
</head>
<body>
<%
    long stuno = StrUtil.toLong(request.getParameter("stuno"), 0L);
    Student stu = StudentService.ME.get(stuno);
%>
<form action="doUpdateStudent.jsp" method="post">
    <p><label>编号:</label>
        <input type="number" value="<%=stu.getStuno()%>" id="id" name="stuno"/>
    </p>
    <p><label>姓名:</label>
    </p>
    <p>   <input type="text" id="sname" name="sname" value="<%=stu.getSname()%>"/>
    </p>
    <p>    <label>入学时间:</label>
        <input type="date" id="hour" name="enterdate" value="<%=StrUtil.toStr(stu.getEnterdate())%>"/>
    </p><p>
        <%
            SqlSession s = MybatisUtil.get();
            GradeDao dao = s.getMapper(GradeDao.class);
            List<Grade> grades = dao.findAll();
            MybatisUtil.close(s);
        %>
        <label>年级号：</label>
        <select id="gradeid" name="gradeid">
            <%
                for (Grade g : grades) {
            %>
            <option value="<%=g.getId()%>"><%=g.getGname()%>
            </option>
            <%}%>
        </select>
    </p>
    <p>
        性别：<input type="radio" name="sex" value="男" />男
        <input type="radio" name="sex" value="女"/>女
        <input type="radio" name="sex" value="妖"/>妖
    </p>

    <input type="submit" value="Add"/>
</form>
<script>
    $(function () {
      $("[name=sex][value=<%=stu.getSex()%>]").prop("checked",true);
      $("[name=gradeid]").val('<%=stu.getGradeid()%>');
    });
</script>
</body>
</html>
